package com.hundun.vision.biz.robot;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ：RuoChen
 * @date ：10:10 2024/11/30
 * @description：策略机器人
 */
@Service
@Slf4j
public class StrategyRobot {
    @Autowired
    private BuyRobot buyRobot;

    @Autowired
    private SellRobot sellRobot;

    public void start() {
        while (true) {
            try {
                buyRobot.check();
                sellRobot.check();
                // 每5秒获取一次市场价格
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                log.error("Error occurred while sleep: {}", e.getMessage());
            } catch (Exception e) {
                log.error("Error occurred while loop: {}", e.getMessage());
            }
        }
    }
}